#pragma once

#define CMD_ADDSENSOR		1001
#define CMD_REMOVESENSOR	1002


typedef struct _SENSOR_FUNCTION{
	BOOL TEMPERATURE;
	BOOL CO2;
	BOOL OI;
}sensorFunction;

class CSensor
{
public:
	CSensor(void);
	CSensor(CPoint point);
	~CSensor(void);

private:
	CPoint m_pos;
	UINT m_id;
	float m_Temperature;
	float m_Humidity;
	float m_Co2;
	int m_OILevel;
	int m_stinks;
	bool m_bMove;
	sensorFunction m_func;
	bool m_bConnected;
	CString m_strLocation;
	COleDateTime m_StartTime;
	COleDateTime m_ElapseTime;
	int m_Co2Alram;
	int m_aliveCnt;
	int m_oldAliveCnt;
	int m_timeoutCnt;

public:
	CPoint m_oldpos;
public:
	void setID(UINT id){m_id=id;};
	UINT getID(){return m_id;};
	void setPosition(CPoint pos){m_pos = pos;};
	void getPosition(CPoint &pos){pos = m_pos;};
	bool getMoving(){return m_bMove;};
	void setMoving(bool bShow){m_bMove = bShow;};
	bool selectCheck(CPoint pos);
	void setSensorFunc(sensorFunction fn){m_func = fn;};
	void setConnectState(bool bConnected){m_bConnected = bConnected;};
	bool getConnectState(){return m_bConnected;};
	void setLocation(CString strLoc){m_strLocation = strLoc;};
	CString getLocation(){return m_strLocation;};

	void setTemperature(float temper){m_Temperature = temper;};
	void setHumidity(float humi){m_Humidity = humi;};
	void setCO2(float co2){m_Co2 = co2;};
	void setOILevel(int lv){m_OILevel = lv;};
	float getTemperature(){ return m_Temperature;};
	float getHumidity(){return m_Humidity;};
	float getCO2(){return m_Co2;};
	int getOILevel(){return m_OILevel;};

	void setStartTime(COleDateTime time){ m_StartTime = time;};
	COleDateTime getStartTime(){return m_StartTime;};
	COleDateTimeSpan getElapseTime(){
		COleDateTime justTime(COleDateTime::GetCurrentTime());
		COleDateTimeSpan gapTime = justTime-m_StartTime;
		return gapTime;
	};

	void setCO2Alram(int alrammode){m_Co2Alram = alrammode;};
	int getCO2Alram(){return m_Co2Alram;};

	void initData();
	bool getTimeOut(); 
	void setAlive();
};

